package operation;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

public class FindOperation implements IOperration {
    @Override
    public void work(BookList bookList) {
        System.out.println("查找书籍");
        Scanner scanner = new Scanner(System.in);
        //输出提示信息
        System.out.println("请输入你要查找的书籍名称：");
        String name = scanner.nextLine();

        for (int i = 0; i < bookList.getUsedSize(); i++) {
            Book book = bookList.getBook(i);
            if(name.equals(book.getName())){
                System.out.println("找到此书如下：");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有这本书！");
    }
}
